-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always close after assert_screen to make test stable. #24
Conversation
f8f252c
to
516bc48
Compare
Would it be possible to move close within teardown?
This can deprecate close() and moves the actual processing into the teardown(). |
Thank you! I updated Yamatanooroti::TestMultiplatform to use both startup(start_terminal) and teardown(close). Tools that use Yamatanooroti can also adopt this approach in their own test.
Doing close-in-teardown by default is not good at writing this kind of test. def test_foobar
start_terminal 5, 30, cmd1
assert_screen foo
close # manual close
start_terminal 5, 30, cmd2
assert_screen bar
# auto close
end We can provide auto close by another approach, similar to start_terminal do # Auto close API
assertions_here
end # close here
start_terminal # Manual close API
assertions_here
close
# Comparison with File API
File.open(path, mode) do |f| # Auto close File API
f.puts text
end
f = File.open(path, mode) # Manual close File API
f.puts text
f.close |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fixes REAME and all test that closes before assertion.
Fixes #18
After #10, assert_screen can be called several times in a single test. We don't have to close before assert_screen anymore.
Closing before assert_screen has some problem. We need #15 to perform test that closes stdin before assertion, so the preferred form is to always close after all assertions.
In #10, I forgot to change the order of
assert_screen
andclose
because test was passing, but it turned out to be flaky.